<template>
  <div>
    <div class="dialogLanguage">
      <div class="canvas animated">
        <div class="container-1">
          <div class="dialog-view">
            <div class="dialog-title">
              语言
              <div class="common-close" @click="closeLanguage">
                <img src="@/assets/images/close.png" />
              </div>
            </div>
            <div class="dialog-container">
              <div class="language-info">
                <div class="locale-list">
                  <div
                    class="locale-item"
                    :class="idx === selected && 'selected'"
                    v-for="(item, idx) in languageList"
                    @click="changeLanguage(idx)"
                    :key="idx"
                  >
                    <div
                      class="icon"
                      :style="`background-image:url(${item.bgImg})`"
                    ></div>
                    <div classs="title">{{ item.title }}</div>
                  </div>
                </div>
              </div>
            </div>
            <!---->
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data: () => ({
    selected: 0,
    languageList: [
      { title: "简体中文", bgImg: require("@/assets/images/china.png") },
      { title: "English", bgImg: require("@/assets/images/theUSA.png") },
    ],
  }),
  methods: {
    changeLanguage(index) {
      this.selected = index;
    },
    closeLanguage() {
      this.$emit("onChangeLanguage", false);
    },
  },
};
</script>
<style  lang="scss" scoped>
@import "./../common/styles/common.scss";
.dialogLanguage {
  .canvas {
    height: 100vh;
    width: 100vw;
    top: 0;
    left: 0;
    z-index: 201;
    position: fixed;
    background-color: transparent;
    -webkit-transition: backround-color 0.2s ease;
    transition: backround-color 0.2s ease;
    background: rgba(0, 0, 0, 0.5);
    .container-1 {
      position: absolute;
      top: 50%;
      left: 50%;
      -webkit-box-sizing: border-box;
      box-sizing: border-box;
      color: #431216;
      opacity: 0;
      -webkit-transform: translateX(-50%) translateY(-50%) scale(0.6);
      transform: translateX(-50%) translateY(-50%) scale(0.6);
      -webkit-transition: opacity 0.4s ease, -webkit-transform 0.4s ease;
      transition: opacity 0.4s ease, -webkit-transform 0.4s ease;
      transition: transform 0.4s ease, opacity 0.4s ease;
      transition: transform 0.4s ease, opacity 0.4s ease,
        -webkit-transform 0.4s ease;
      opacity: 1;
      -webkit-transform: translateX(-50%) translateY(-50%) scale(1);
      transform: translateX(-50%) translateY(-50%) scale(1);
    }
    .dialog-view {
      background: #fff;
      font-size: 14px;
      min-width: 320px;
      border-radius: 16px;
      @media screen and (max-width: 960px) {
        width: calc(100vw - 30px);
      }
    }

    .dialog-title {
      height: 74px;
      font-size: 20px;
      font-weight: 700;
      padding: 0 48px;
      position: relative;
      text-align: center;
      color: #431216;
      word-break: break-word;
      display: -webkit-box;
      display: -ms-flexbox;
      display: flex;
      -webkit-box-align: center;
      -ms-flex-align: center;
      align-items: center;
      -webkit-box-pack: center;
      -ms-flex-pack: center;
      justify-content: center;
      line-height: 1.1;
      @media screen and (max-width: 960px) {
        height: 60px;
        font-size: 18px;
        padding: 0 32px;
      }
      .common-close {
        position: absolute;
        right: 20px;
        height: 14px;
        width: 14px;
        top: 50%;
        -webkit-transform: translateY(-50%) rotate(45deg);
        transform: translateY(-50%) rotate(45deg);
        text-indent: -999em;
        text-indent: 0;
        -webkit-transform: translateY(-50%) rotate(0deg);
        transform: translateY(-50%) rotate(0deg);
        width: 18px;
        height: 18px;
      }
    }
    .dialog-container {
      padding: 0 28px;
      max-height: calc(100vh - 154px);
      overflow: auto;
      -webkit-overflow-scrolling: touch;
      @media screen and (max-width: 960px) {
        padding: 0 18px;
        max-height: calc(100vh - 140px);
      }
      .language-info {
        width: 520px;
        @media screen and (max-width: 960px) {
          width: auto;
        }
        .locale-list {
          display: -webkit-box;
          display: -ms-flexbox;
          display: flex;
          -ms-flex-wrap: wrap;
          flex-wrap: wrap;
          padding-bottom: 30px;
          @media screen and (max-width: 960px) {
            padding-bottom: 20px;
          }
          .locale-item {
            width: calc(33.33333% - 12px);
            padding: 10px 12px;
            font-size: 14px;
            display: -webkit-box;
            display: -ms-flexbox;
            display: flex;
            -webkit-box-align: center;
            -ms-flex-align: center;
            align-items: center;
            color: #694f4e;
            cursor: pointer;
            font-weight: 400;
            margin: 4px 6px;
            border-radius: 12px;
            border: 1px solid transparent;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            -webkit-transition: background-color 0.2s ease,
              border-color 0.2s ease;
            transition: background-color 0.2s ease, border-color 0.2s ease;
            @media screen and (max-width: 960px) {
              width: calc(50% - 12px);
              margin: 4px 6px;
            }

            .icon {
              width: 22px;
              height: 22px;
              background-size: 100% 100%;
              background-repeat: no-repeat;
              margin-right: 12px;
              -webkit-box-shadow: 1px 1px 2px rgb(0 0 0 / 12%);
              box-shadow: 1px 1px 2px rgb(0 0 0 / 12%);
              border-radius: 22px;
            }
          }
          .selected {
            font-weight: 700;
            border-color: #fad551;
            color: #431216;
            background: rgba(250, 213, 81, 0.12);
          }
        }
      }
    }
  }
}
</style>